﻿using Device.API.Applcation.Command.EquipmentCommand;
using Device.Infrstructre.Interface;
using MediatR;

namespace Device.API.Applcation.CommandHandlers.EquipmentCommandHandlers
{
    public class UptEquipmentCommandHandlers:IRequestHandler<UptEquipmentCommand, int>
    {

        private readonly IEquipmentRepository _equipmentRepository;
        public UptEquipmentCommandHandlers(IEquipmentRepository equipmentRepository)
        {
                _equipmentRepository = equipmentRepository;
        }

        public async Task<int> Handle(UptEquipmentCommand request, CancellationToken cancellationToken)
        {


            return await _equipmentRepository.UpdateAsync(new Domain.EquipmentModel() { AddName = request.AddName,EquipmentCode=request.EquipmentCode, EquipmentId = request.EquipmentId, EquipmentName = request.EquipmentName, AuthorIdentifier = request.AuthorIdentifier, IsAuthorize = request.IsAuthorize, EquipmentState = request.EquipmentState, Eremark = request.Eremark, AddTime = request.AddTime, Office_Id = request.Office_Id, User_Id = request.User_Id });
        }
    }
}
